bool Compare(TFunc *a, TFunc *b)
{
    return a->power > b->power;
}

void QuickSort(TFunc *start, TFunc *end, bool (*Compare)(TFunc*, TFunc*))
{
    TFunc *left, *right;
    TFunc flag, temp;

    while (start < end)
    {
        left  = start;
        right = end;
        flag  = *(start + ((end - start) >> 1));
        do
        {
            while (Compare(left, &flag)) left++;
            while (Compare(&flag, right)) right--;

            if (left < right)
            {
                temp   = *right;
                *right = *left;
                *left  = temp;
                right--;
                left++;
            }
            else if (left == right)
            {
                right--;
                left++;
                break;
            }
        } while (left <= right);

        if (start < right)
            QuickSort(start, right, Compare);

        start = left;
    }
}